
    DEF INPUT PARAMETER p-rowid AS CHAR   NO-UNDO.

    FIND docld WHERE ROWID(docld) = TO-ROWID(p-rowid) NO-ERROR.

    IF AVAILABLE docld THEN DO:
       FOR EACH dliv WHERE dliv.nosoc  = docld.nosoc
                       AND dliv.typdoc = docld.typdoc
                       AND dliv.prefix = docld.prefix
                       AND dliv.nodoc  = docld.nodoc
                       AND dliv.noseq  = docld.noseq:
           DELETE dliv.
       END.

       FOR EACH docli WHERE docli.nosoc  = docld.nosoc
                        AND docli.typdoc = docld.typdoc
                        AND docli.prefix = docld.prefix
                        AND docli.nodoc  = docld.nodoc
                        AND docli.noseq  = docld.noseq:
           DELETE docli.
       END.

       FOR EACH docnom WHERE docnom.nosoc  = docld.nosoc
                         AND docnom.typdoc = docld.typdoc
                         AND docnom.prefix = docld.prefix
                         AND docnom.nodoc  = docld.nodoc
                         AND docnom.noseq  = docld.noseq:
           DELETE docnom.
       END.

       doce.totmtn  = doce.totmtn - docld.montne - IF docld.taxi THEN 0
                                                    ELSE docld.montx.
       doce.totqte  = doce.totqte - docld.montx.
       doce.totme   = doce.totmtn.

       DELETE docld.
    END.
